#include <bits/stdc++.h>
#define ll long long
using namespace std;

inline ll read(){
    ll x=0;char c=getchar();
    while (!isdigit(c))c=getchar();
    while (isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x;
}

struct car{
    ll d,v,a;
}p[200005];
ll d[200005],tree[200005],n,m,l,v;

void upd(ll pos,ll v){
    while (pos<=m){
        tree[pos]+=v;
        pos+=pos&-pos;
    }
}

ll query(ll pos){
    ll ans=0;
    while (pos){
        ans+=tree[pos];
        pos-=pos&-pos;
    }
    return ans;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    cin >> t;
    while (t--){
        cin >> n >> m >> l >> v;
        for (ll i=1;i<=n;i++){
            cin >> p[i].d >> p[i].v >> p[i].a;
        }
        for (ll i=1;i<=m;i++){
            cin >> d[i];
        }
        sort(d+1,d+1+m);
        vector<pair<ll,ll>> vct;
        for (ll i=1;i<=n;i++){
            ll D=v*v-p[i].v*p[i].v;
            if (p[i].a==0){
                if (p[i].v>v){
                    ll l=0,r=m+1;
                    while (l+1<r){
                        ll mid=(l+r)>>1;
                        if (d[mid]<p[i].d)l=mid;
                        else{
                            r=mid;
                        }
                    }
                    if (r<=m)
                    vct.push_back({r,m});
                }
            }else if (p[i].a<0){
                ll l=0,r=m+1;
                while (l+1<r){
                    ll mid=(l+r)>>1;
                    if (d[mid]<p[i].d)l=mid;
                    else{
                        r=mid;
                    }
                }
                ll lb=r;
                l=0,r=m+1;
                while (l+1<r){
                    ll mid=(l+r)>>1;
                    if (d[mid]<p[i].d)l=mid;
                    else{
                        ll s=d[mid]-p[i].d;
                        if (2*p[i].a*s<=D){
                            r=mid;
                        }else{
                            l=mid;
                        }
                    }
                }
                ll rb=l;
                if (lb<=rb)
                vct.push_back({lb,rb});
            }else if (p[i].a>0){
                ll l=0,r=m+1;
                while (l+1<r){
                    ll mid=(l+r)>>1;
                    if (d[mid]<p[i].d)l=mid;
                    else{
                        ll s=d[mid]-p[i].d;
                        if (2*p[i].a*s>D){
                            r=mid;
                        }else{
                            l=mid;
                        }
                    }
                }
                if (r<=m)
                vct.push_back({r,m});
            }
        }
        sort(vct.begin(),vct.end(),[](pair<ll,ll> a,pair<ll,ll> b){
            if (a.second==b.second)
                return a.first<b.first;
           return a.second<b.second;
        });
        ll ans=0;
        for (auto i:vct){
                //cout<<i.first<<","<<i.second<<"\n";
            if (query(i.second)-query(i.first-1)==0){
                upd(i.second,1);
                ans++;
            }
        }
        cout<<vct.size()<<" "<< m-ans<<"\n";
        for (ll i=1;i<=m;i++)tree[i]=d[i]=0;
    }
    return 0;
}
